#pragma once

#include <SDL2/SDL.h>
#include "defines.h"

extern "C" {
    typedef struct _TTF_Font TTF_Font;
}

struct MenuContext;

class Menu {
public:
    enum {
        Invalid = -1,
        Button = 0,
        Checkbox = 1,
        Radio = 2,
    };
public:
    Menu(SDL_Renderer *renderer, TTF_Font *font, int height = 20, int align = 0, SDL_Color color = {255, 255, 255, 255});
    virtual ~Menu();

    int addButton(const char *text, const char *image = nullptr);
    int addCheckbox(const char *text, const char *image = nullptr, bool checked = false);
    int addRadio(const char *text, const char *image = nullptr, int group = 0, bool checked = false);

    int getIndex();
    int getCount();

    bool isChecked(int index);
    void setChecked(int index, bool checked);
    int getRadioChecked(int group);
    int getType(int index);

    int processEvents(SDL_Event &ev);

    void render(const SDL_Point &pt);

private:
    MenuContext *context;
};
